package com.M10.BE.fragment;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.M10.BE.R;
import com.M10.BE.adapter.NInveLoseAdapter;
import com.M10.BE.adapter.NNewAdapter;
import com.M10.BE.entity.NAsset;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/14.
 */
public class AssetLostListFragment extends BaseFragment implements View.OnClickListener, FragmentLifecycle {
    private Context context;
    private ArrayList<NAsset> assetLists = new ArrayList<NAsset>();
    private ListView listView;
    NInveLoseAdapter nInveLoseAdapter = null;
    View view = null;
    public static Handler mHandler = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = getActivity();
        mHandler = sHandler;
    }

    protected void initView(View view, LayoutInflater inflater) {
        listView = (ListView) view.findViewById(R.id.listview_fragment);
        nInveLoseAdapter = new NInveLoseAdapter(context, assetLists,
                listView);
        listView.setAdapter(nInveLoseAdapter);
    }
    @Override
    protected int getLayoutId() {
        return R.layout.listview_asset_fragment;
    }



    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onResume() {
        super.onResume();
        Toast.makeText(context, "盘亏列表", Toast.LENGTH_SHORT).show();
    }
    private Handler sHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            List<NAsset> list = (List<NAsset>) msg.obj;
            nInveLoseAdapter.setList(list);
            nInveLoseAdapter.notifyDataSetChanged();
        }
    };
    @Override
    public void onClick(View v) {
//        if (v == header_close) {
//            listView.removeHeaderView(header);
//            PreferenceShareTools.setRelationMarkFirstIn(context, ChanceApplication.getCID(), false);
//        }
    }


    /**
     * 这个类用来异步加载陌生人和mark的的信息
     *
     * @author Muhuan
     */

    @Override
    public void onPauseFragment() {
    }

    @Override
    public void onResumeFragment() {
    }

    @Override
    public void onPostFragment() {
    }
}
